#ifndef _ZUC_CAN_DUMPER_H_
#define _ZUC_CAN_DUMPER_H_

#include <cstdint>
#include "controlcan/controlcan.h"
#include "diagconfig.h"

typedef struct
{
    int32_t mtnNo;  // motion number
    uint32_t id;
    uint8_t data[128];
    size_t size;
    bool is_tx;
    uint64_t timestamp_;
    bool is_ext;
} zucDiagBusMsg;

typedef struct zucDiagSCBVersion
{
    int32_t majorVer;
    int32_t minorVer;
} zucDiagSCBVersion;

typedef struct zucDiagServoVersion
{
    int32_t ver;
} zucDiagServoVersion;

typedef enum class zucDiagVerType
{
    SCB_VERSION,
    SERVO_VERSION,
} zucDiagVerType;

typedef union zucDiagVerData
{
    zucDiagServoVersion servo;
    zucDiagSCBVersion scb;
} zucDiagVerData;

/**
 * @param flag 1 手动触发诊断/ 0 手动停止诊断
 * @brief 用于启动或停止诊断; 诊断中再次诊断时, 会延长诊断时间
 */
int32_t zucDiagCollectData(int32_t flag);

/**
 * 用于检查当前是否在诊断中
 */
int32_t zucDiagIsCollectingData();

/**
 * 设置当前加载程序文件路径
 */
int32_t zucDiagSetLoadedProgram(const char* file);

/**
 * 错误码触发诊断; 诊断中再次触发, 会延长诊断时间
 */
int32_t zucDiagEcode(uint32_t ecode);

/**
 * 记录motionbus报文
 */
int32_t zucDiagBus(const zucDiagBusMsg& msg);

// 初始化诊断环境
int32_t zucDiagInit();

// 逆初始化诊断运行环境
int32_t zucDiagDeInit();

/**
 * 更新诊断记录中的版本信息
 */
int32_t zucDiagUpdateVerInfo(zucDiagVerType verType, zucDiagVerData verData);

/**
 * 测试用：修改当前的诊断时间、诊断延长步长和最大值
 */
int32_t zucDiagConfig(uint32_t baseDur, uint32_t stepDur, uint32_t maxDur);

#endif